package com.flymobi.util;

public class QL {
	public static final class HQL {

		public static class Manager {
			public static final String LIST = "from Manager m ORDER BY m.id DESC";
			public static final String FIND_BY_NAME = "from Manager m where m.name=?";
			public static final String GET_COUNT = "SELECT COUNT(*) FROM Manager m";
			public static final String LIST_KEY = "from Manager m where m.name like ? ORDER BY m.id DESC";
			public static final String GET_COUNT_KEY = "SELECT COUNT(*) FROM Manager m where m.name like ?";
		}

		public static final class SysPower {
			public static final String LIST = "FROM SysPower m WHERE m.rolesId=?";
			public static final String DELETE_BY_MENUID = "DELETE FROM SysPower m WHERE m.sysMenuId=?";
			public static final String DELETE_BY_RolesID = "DELETE FROM SysPower m WHERE m.rolesId=?";
		}

		public static final class SysMenu {
			public static final String LIST = "FROM SysMenu m WHERE m.fatherId=? order by m.idx";
			public static String LIST_BY_POWER = "FROM SysMenu m WHERE m.fatherId=? and m.id in(SELECT s.sysMenuId FROM SysPower s WHERE s.rolesId=?) order by m.idx";
		}

		public static final class Roles {

			public static final String LIST = "from Roles m ORDER BY m.id DESC";

		}

		public static final class Cls {
			public static final String GET_MAX_IDX = "select max(idx)+1 from Cls m where m.fatherId=?";
			public static final String LIST = "from Cls m where m.fatherId=0 ORDER BY m.idx";
			public static final String LIST_SHOW = "from Cls m where m.fatherId=0 and shows=true ORDER BY m.idx";
			public static final String LIST_SUB = "from Cls m where m.fatherId=? ORDER BY m.idx ";
			public static final String LIST_SUB_SHOW = "from Cls m where m.fatherId=? and shows=true ORDER BY m.idx ";
			public static final String LIST_UP = "FROM Cls m WHERE m.fatherId=? and m.idx<? order by m.idx desc";
			public static final String LIST_DOWN = "FROM Cls m WHERE m.fatherId=? and m.idx>? order by m.idx asc";
		}

		public static final class Res {
			public static final String Get_Prev = "from Res m where m.id<? and m.clsId=? and m.status=1 order by m.id desc";
			public static final String Get_Next = "from Res m where m.id>? and m.clsId=? and m.status=1 order by m.id asc";
			public static final String GET_PINDAO_COUNT = "SELECT COUNT(*) FROM Res m where (m.clsId=? or m.clsId in(select p.id from Cls p where p.fatherId=?)) and m.status=1";
		}

		public static final class ResFile {
			public static final String LIST = "from ResFile m where m.resId=? ORDER BY m.id DESC";
			public static final String GET_COUNT = "SELECT COUNT(*) FROM ResFile m where m.resId=? ";
			public static final String LIST_ALL = "from ResFile m where m.resId in(?,?) ORDER BY m.idx";
			public static final String LIST_UP = "FROM ResFile m WHERE m.resId=? and m.idx<? order by m.idx desc";
			public static final String LIST_DOWN = "FROM ResFile m WHERE m.resId=? and m.idx>? order by m.idx asc";
			public static final String GET_MAX_IDX = "select max(idx)+1 from ResFile m where m.resId=?";
		}

		public static final class SysParam {

			public static final String FIND="from SysParam m where m.name=?";
			
		}


	}

	public static final class SQL {

		public static final class MYSQL {
			public static final class PAGINATION {
				public static String SQL(String sql, int startRows,
						int pagePerSize) {
					return "select * from (" + sql + ") ttt order by c1 desc limit " + startRows
							+ "," + pagePerSize;
				}
			}

			public static final class TONGJI {
				
			}  
		}
	}
}